/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.business.ets;

import com.herenit.beijing.dh2011.business.base.BaseManager;
import com.herenit.beijing.dh2011.entity.EtConcepts;
import com.herenit.beijing.dh2011.entity.EtVersions;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

/**
 *
 * @author Obama
 */
@Stateless
public class EtsService extends BaseManager implements EtsServiceRemote {
    
    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public List<EtConcepts> findByVersionId(long id) {
        //   List<EtConcepts> ets = new ArrayList<EtConcepts>();

        //List<EtConcepts> queryList = em.createQuery("select e from EtConcepts e left join e.etVersions v where v.id=:id").setParameter("id", id).getResultList();
        
        List<EtConcepts> queryList = em.createQuery("select e from EtConcepts e where e.etVersions.id=:id").setParameter("id", id).getResultList();
        for (EtConcepts et : queryList) {
              et.setEtVersions(null);
             et.setChildren(null);
        }
        return queryList;
        
    }
    
    @Override
    public List<EtConcepts> testReturnList() {
        List<EtConcepts> ets = new ArrayList<EtConcepts>();
        
        EtConcepts et = new EtConcepts();
        et.setConceptCode("123");
        et.setConceptName("haha");
        et.setEtVersions(new EtVersions());
        et.setCreatedBy(12321l);
        et.setParents(null);
        et.setStatusCode("321321");
        
        
        ets.add(new EtConcepts());
        
        return ets;
    }
}
